{include app:admin.inc.header}
<!--tmpl-resource-->
{include app:admin.inc.top}
<style>
	.form-horizontal .form-message label{text-align: right;margin-right: 5px;padding-top: 0px;}
	.fourLinkage{/* border-top:1px solid #eee; */border-bottom:1px solid #eee;padding: 10px 0px;margin: 0px 0px 10px;}
</style>

<div class="container-fluid content-body">
	<div class="main">
		<!-- left side start-->
		<section class="left-section">
			<dl id="leftNav" data-type="order">
				<dt><i class="glyphicon glyphicon-shopping-cart"></i> 交易管理</dt>
				{if in_case_array('admin/order/add',$priv) || empty($priv)}
				<dd><a class="mb  active" href="{url /admin/order/add}">添加订单</a></dd>
				{/if}
				{if in_case_array('admin/order',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/order/index}">订单列表</a></dd>
				{/if}
				{if in_case_array('admin/contract',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/contract/index}">合同列表</a></dd>
				{/if}
			</dl>
		</section>
		<!-- left side end-->


		<!-- main content start-->
		<section class="right-section" id="right-section">
			{include admin.inc.bread}
			<h2 class="header">{$title}</h2>
			<!-- start of inner-frame -->
			<div class="inner-iframe">
				<!-- Nav tabs -->
				
				<div class="inner-container">
					<form role="form" class="form-horizontal basicForm content-add-form" id="content-add-form" autocomplete="off">
						{if $id != ''}
						<div class="fourLinkage">
							<!--tmpl-fields-->

							<!-- input -->
							<div class="form-group form-message">
								<label class="col-sm-2 control-label">会员帐号 </label>
								<div class="col-sm-4">
									{$item[company][username]}
									<input type="hidden" name="member_id" value="{$item[member_id]}">
								</div>
							</div>
							{if $item[shipping_way]==$SHIPPING_WAY_SELLER}
							<div class="form-group form-message">
								<label class="col-sm-2 control-label">收货地址 </label>
								<div class="col-sm-6">
									<div><span>&nbsp;{$item[address][consignee]}&nbsp;{$item[address][contact_mobile]}&nbsp;&nbsp;{$item[address][address]}&nbsp;&nbsp;{$item[address][zip_code]}</span></div>
								</div>
								<p style="color: red;font-size: 12px;">（如无需更改请勿勾选下面收货地址）</p>
							</div>
							{else}
							<div class="form-group">
								<label class="col-sm-2 control-label">买家自提信息 </label>
								<div class="col-sm-6">
									提货人:{$item[shipping][shipping_fullname]}
									<br/>提货人电话:{$item[shipping][shipping_mobile]}
									<br/>提货人车辆牌号:{$item[shipping][shipping_car_card]}
									<br/>提货人身份证:{$item[shipping][shipping_id_card]}
									<br/>提货日期:{$item[shipping][shipping_time]}
								</div>
							</div>
							{/if}
						</div>
						{else}
						<div class="fourLinkage">
							<!--tmpl-fields-->

							<!-- input -->
							<div class="form-group">
								<label class="col-sm-2 control-label"><span class="asterisk">*</span>会员帐号 </label>
								<div class="col-sm-4">

									<input type="text" class="form-control" name="member_phone"
										   placeholder="手机号码搜索" required cname="手机号码搜索" value="">
                                    <input type="hidden" required placeholder="请输入正确手机号码点击搜索" empty-message="请输入正确手机号码点击搜索" name="member_id" value="">
								</div>
								<div class="col-sm-1">
									<a href="javascript:void(0);" class="btnsm-primary" id="member_search"> 搜索</a>
								</div>
								<div class="col-sm-4">
									<p class="help-block"></p>
								</div>
							</div>
						</div>
						{/if}

						<h2 class="header">交收设置</h2>
						<div class="fourLinkage">


							<div class="form-group">
								<label class="col-sm-2 control-label"><span class="asterisk">*</span>支付方式</label>
								<div class="col-sm-4">

									<select class="form-control select_type " required cname="支付方式" name="data[pay_way]" id="pay_way" data-name="支付方式">
										<option value="">请选择</option>
										{if $item && $item[add_type]!=$ADD_TYPE_SELLER}<option value="0" {if $item && $item[pay_way]!=$PAY_WAY_OFFLINE} selected="selected"{/if}>线上支付</option>{/if}
										<option value="1" {if $item && $item[pay_way]==$PAY_WAY_OFFLINE} selected="selected"{/if}>线下支付</option>
									</select>
								</div>

								<p class="help-block"></p>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label"><span class="asterisk">*</span>交收方式</label>
								<div class="col-sm-4">

									<select class="form-control select_type " required cname="交收方式" name="data[shipping_way]" id="shipping_way"
											data-name="交收方式">
										<option value="">请选择</option>
										<option value="0" {if $item && $item[shipping_way]==$SHIPPING_WAY_SELLER} selected="selected"{/if}>卖家配送</option>
										<option value="1" {if $item && $item[shipping_way]==$SHIPPING_WAY_BUYER} selected="selected"{/if}>买家自提</option>
									</select>
								</div>

								<p class="help-block"></p>
							</div>
						</div>
						<div class="shipping_way_get{if $item[shipping_way]==$SHIPPING_WAY_SELLER} hidden{/if}">
							<h2 class="header">提货人信息</h2>
							<div class="fourLinkage">

								<div class="form-group">
									<label class="col-sm-2 control-label"><span class="asterisk">*</span>提货人姓名</label>
									<div class="col-sm-4">
										<input type="text" name="shipping[shipping_fullname]" class="form-control" placeholder="提货人姓名" value="{$item[shipping][shipping_fullname]}" required />
									</div>
								</div>
								<p class="help-block text-error"></p>

								<div class="form-group">
									<label class="col-sm-2 control-label"><span class="asterisk">*</span>提货人手机号码</label>
									<div class="col-sm-4">
										<input type="text" name="shipping[shipping_mobile]" dtype="mobile" class="form-control" placeholder="提货人手机号码" value="{$item[shipping][shipping_mobile]}" required />
									</div>
								</div>
								<p class="help-block text-error"></p>

								<div class="form-group">
									<label class="col-sm-2 control-label"><span class="asterisk">*</span>提货人车辆牌号</label>
									<div class="col-sm-4">
										<input type="text" name="shipping[shipping_car_card]" class="form-control" placeholder="提货人车辆牌号" value="{$item[shipping][shipping_car_card]}" required />
									</div>
								</div>
								<p class="help-block text-error"></p>

								<div class="form-group">
									<label class="col-sm-2 control-label">提货人身份证</label>
									<div class="col-sm-4">
										<input type="text" name="shipping[shipping_id_card]" maxlength="18" class="form-control" value="{$item[shipping][shipping_id_card]}" placeholder="提货人身份证" />
									</div>
								</div>

								<div class="form-group">
									<label class="col-sm-2 control-label"><span class="asterisk">*</span>提货日期</label>
									<div class="col-sm-4">
										<input style="width:100px;" class="form-control mdate" dtype="time" size="16" type="text"
											   name="shipping[shipping_time]" value="{$item[shipping][shipping_time]}"
											   placeholder="提货日期" required />
									</div>
								</div>
								<p class="help-block text-error"></p>

								<div class="form-group">
									<label class="col-sm-2 control-label">提货补充</label>
									<div class="col-sm-4">
										<textarea dtype="" class="form-control" maxlength="{maxlength}" name="shipping[shipping_remark]" placeholder="提货补充" cname="提货补充">{$item[shipping][shipping_remark]}</textarea>
									</div>
								</div>

							</div>
						</div>
						<div class="shipping_way_send{if $item[shipping_way]!=$SHIPPING_WAY_SELLER} hidden{/if}">
							<h2 class="header clearfix" style="padding:0;"><span style="margin-top: 8px; display: inline-block;">选择送货地址</span><button type="button" class="btnlg mb {if $id == ''}disabled{/if}" id="new_add_address" style="float: right"><i class="css-add"></i>新增收货地址</button> </h2>
							
							<div class="fourLinkage" style="border-top: none;">

								<div class="form-group">
									<label class="col-sm-2 control-label"></label>
									<div class="col-sm-8" id="address_list">
										{if $address_item}
										{loop $address_item $v}
										<div><input type="radio" name="address_id" id="address_id_{$v[id]}" value="{$v[id]}"><label for="address_id_{$v[id]}">&nbsp;{$v[consignee]}&nbsp;{$v[contact_mobile]}&nbsp;&nbsp;{$v[detail_address]}&nbsp;&nbsp;{$v[zip_code]}</label></div>
										{/loop}
										{/if}
									</div>
								</div>
								<!-- input -->
								<div id="address_form" style="display: none">
									<div class="form-group">

										<label class="col-sm-2 control-label"><span class="asterisk">*</span>收货地区</label>
										<div class="col-sm-8">
											<div class="area-wrap"></div>
										</div>

									</div>
									<p class="help-block"></p>

									<div class="form-group">
										<label class="col-sm-2 control-label"><span class="asterisk">*</span>详细地址 </label>
										<div class="col-sm-4">

											<input type="text" class="form-control" maxlength="20" name="address[address]"
												   placeholder="街道地址" cname="街道地址" value="">
										</div>

									</div>
									<p class="help-block"></p>

									<div class="form-group">
										<label class="col-sm-2 control-label">邮政编码 </label>
										<div class="col-sm-4">

											<input type="text" class="form-control" maxlength="6" name="address[zip_code]"
												   placeholder="邮政编码" cname="邮政编码" value="">
										</div>

									</div>
									<p class="help-block"></p>

									<div class="form-group">
										<label class="col-sm-2 control-label"><span class="asterisk">*</span>收货人姓名 </label>
										<div class="col-sm-4">

											<input type="text" class="form-control" name="address[consignee]"
												   placeholder="收货人姓名" cname="收货人姓名" value="">
										</div>

									</div>
									<p class="help-block"></p>

									<!-- input -->
									<div class="form-group">
										<label class="col-sm-2 control-label"><span class="asterisk">*</span>手机 </label>
										<div class="col-sm-4">

											<input type="text" dtype="mobile" cname="手机号码" class="form-control" name="address[contact_mobile]"
												   placeholder="收货人联系方式" cname="收货人联系方式" value="">
										</div>

									</div>
									<p class="help-block"></p>

									<!-- input -->
									<div class="form-group">
										<label class="col-sm-2 control-label">固定电话 </label>
										<div class="col-sm-4">

											<input type="text" class="form-control" name="address[telephone]"
												   placeholder="固定电话" cname="固定电话" value="">
										</div>

									</div>
									<p class="help-block"></p>
									<a class="btnsm-primary" id="add_address">确定</a>
									<a class="btnsm-danger" id="close_add_address">取消</a>
								</div>
							</div>
						</div>
						<h2 class="header">添加订单明细</h2>
						<div class="fourLinkage">
							<!-- input -->
							{if $id == ''}<div class="form-group">
								<label class="col-sm-2 control-label"><span class="asterisk">*</span>添加商品 </label>
								<div class="col-sm-4">

									<input type="text" class="form-control" name="product_no"
										   placeholder="货号搜索" cname="货号搜索" value="">
								</div>
								<div class="col-sm-5">
									<input type="hidden" required placeholder="添加商品" empty-message="请输入货号搜索或者商品库选择产品" name="have_products" value="">
									<a href="javascript:void(0);" class="btnsm-primary" id="product_search"> 搜索</a>
									<a href="javascript:void(0);" class="btnsm-success" id="select_product"> 商品库</a>
									<span class="help-block" style="display: inline"></span>
								</div>
							</div>{/if}

							<!-- input -->
							<div class="form-group">
								<label class="col-sm-2 control-label">商品 </label>
								<div>
									<div class="table-responsive">
										<table class="table table-hover" style="color: #ccc;">
											<!--tmpl-listtable-->

											<!-- listblock -->
											<thead>
											<tr>
												<th width="180">商品</th>
												<th>货号</th>
												<th>销售价(元/{$pro_unit})</th>
												{if $id==''}<th>会员价(元/{$pro_unit})</th>{/if}
												<th>库存数量({$pro_unit})</th>
												<th>最小交易量({$pro_unit})</th>
												<th>购买数量({$pro_unit})</th>
												<th>原金额(￥)</th>
												<th>现金额(￥)</th>
												<th>涨价或优惠(￥)</th>
												{if $id==''}<th>操作</th>{/if}
											</tr>
											</thead>
											<tbody class="product_list">
											{if !empty($item[product])}
											{loop $item[product] $v}
											<tr id="product_id_{$v[product_id]}">
												<input type="hidden" name="product[product_id][]" value="{$v[product_id]}">
												<input type="hidden" name="product[product_price][]" class="sales_price" value="{$v[product_price]}">
												<td>{$v[product_title]}</td>
												<td style="word-wrap:break-word;word-break:break-all;">{$v[product_no]}</td>
												<td>{$v[product_price]}</td>
												<td>{$v[max_volume]}</td>
												<td>{$v[min_volume]}</td>
												<td class="col-sm-1">{$v[product_quantity]}</td>
												<td class="origin_price">{$v[product_total_price]}</td>
												<td class="col-sm-1"><input type="text" class="form-control now_price" name="product[product_actual_price][]" placeholder="金额" cname="金额" value="{$v[product_actual_price]}" {if $item[order_mode]!=$DIRECTRADE && $item[order_status]>$WAIT_FOR_MERCHANT_CONFIRMATION}readonly{/if}></td>
												<td class="col-sm-2 discount">{$v[discount]}</td>
												<!--<td><a href="javascript:void(0);" class="btn btn-danger btn-xs product_del"><i class="glyphicon glyphicon-trash"></i> 删除</a></td>-->
											</tr>
											{/loop}
											{/if}
											</tbody>
										</table>

									</div>
								</div>

							</div>


							<!-- input -->
							<div class="form-group">
								<label class="col-sm-2 control-label">卖家备注 </label>
								<div class="col-sm-4">

							<textarea dtype="" class="form-control" maxlength="{maxlength}"
									  name="data[sellers_remark]" placeholder="卖家备注" cname="卖家备注">{$item[sellers_remark]}</textarea>
								</div>
							</div>

							<div class="form-group form-message">
								<label class="col-sm-2 control-label">商品总额</label>
								<div class="col-sm-4">
									￥<b id="total_price">{if $id==''}0{else}{$item[actual_amount]}{/if}</b>
								</div>
							</div>
							<p class="help-block"></p>



							<!--tmpl-assocfields-->
						</div>
						<div class="btn-group btn-group-or col-sm-offset-2 inline-top">
							<a href="{if $id==''}{$do_add_url}{else}{$do_edit_url}?id={$id}{/if}" class="btnsm mb ajaxproxy"
							   proxy='{"method":"post", "location":"{$index_url}"}'>提交保存</a>
							<span class="or">OR</span>
							<button type="reset" class="btnsm mc mch">重置表单</button>
						</div>
					</form><!-- content add form -->
				</div>
			</div><!-- end of inner -->
		</section>
	</div>
</div>
{include admin.inc.footer}

<!--tmpl-script-->

<!-- pagescript -->
<script type="text/javascript">
	seajs.use("admin/trading_orderadd",function (exports){
		exports.init({
			searchMemberUrl : '/admin/order/searchMember',//手机号搜索用户收货地址
			searchProductrUrl : '/admin/order/searchProduct',//货号搜索商品
			searchProductListrUrl : '/admin/product/searchProductList',//商品库
			addAddressUrl : '/admin/order/addAddress'//运营商添加收货地址
		});
	});
</script>


<script id="assocpage" type="text/html">
	<div class="text-right">
		<ul class="pagination blog-pagination">
			<li><a class="assoc-page" data-page="{[prev]}" href="javascript:void(0);">上一页</a></li>
			{[loop pages page]}

			<li ><a class="assoc-page" data-page="{[page]}" {[if curr == page]}class="active"{[/if]} href="javascript:void(0)">{[page]}</a></li>

			{[/loop]}
			<li><a class="assoc-page" href="javascript:void(0);" data-page="{[nexts]}">下一页</a></li>
		</ul>
	</div>
</script>

</body>
</html>
